#ifndef _ALLEG_C
#define _ALLEG_C

//includes
#include "alleg.h"

//Functions
// Initialize allegro, Keyboard, Timer, and other necessities
int init_all(int gfx_w, int gfx_h){
    allegro_init();
    install_keyboard();
    install_timer();
    install_mouse(); //Not needed at this time
    if (install_sound( DIGI_AUTODETECT, MIDI_NONE, "" ) != 0)
    {
        allegro_message( "Unable initialize sound module\n%s\n",
                        allegro_error );
        return -1;
    }
    //initialize the screen to 640 * 480
    if (set_gfx_mode(GFX_AUTODETECT_WINDOWED,gfx_w,gfx_h,0,0)!=0){
        allegro_message("Unable initialize graphics module\n%s\n", allegro_error);
        return -1;
    }
    return 0;
}

//Draw Buffer to screen
void draw_buffer(BITMAP *bmp,int source_x,int source_y,int dest_x, int dest_y, int x, int y){
     acquire_screen();
     blit(bmp,screen,source_x,source_y,dest_x,dest_y,x,y);
     release_screen();
}

//Change resolution
int change_res(int gfx_w, int gfx_h){
    if (set_gfx_mode(GFX_AUTODETECT,gfx_w,gfx_h,0,0)!=0){
        allegro_message("Unable initialize graphics module\n%s\n", allegro_error);
        return -1;
    }
    return 0;
}           

#endif
